﻿// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");


using CompositePattern;

/**
 * Composite Pattern Example
 * 组合模式
 * This example demonstrates the Composite Design Pattern, which allows you to compose objects into tree structures
 * to represent part-whole hierarchies. It lets clients treat individual objects and compositions uniformly.
 */
var list = Recursion.GetAllDirectories("E:\\NetCore");
foreach (var item in list)
{
    Console.WriteLine(item.FullName);
}
Console.WriteLine(list.Count);



// 利用递归的方式计算项目提成
double total = 1000000;
// 公司交税 5个点 95% 公司收入  成本45% 利润 50% 董事会 80%
// 其余20%  CEO 30%
// 
#region MyRegion
Domain domain = new Domain() { Name = "能有的提成收入", Percent = 10 };
Domain domain1 = new Domain() { Name = "CEO", Percent = 30 };
var domain2 = new Domain() { Name = "各部门共有", Percent = 70 };
domain.AddChild(domain1);
domain.AddChild(domain2);

var domain21 = new Domain() { Name = "实施", Percent = 20 };
var domain22 = new Domain() { Name = "测试", Percent = 10 };
var domain23 = new Domain() { Name = "销售", Percent = 30 };
var domain24 = new Domain() { Name = "开发部门", Percent = 40 };
domain2.AddChild(domain21);
domain2.AddChild(domain22);
domain2.AddChild(domain23);
domain2.AddChild(domain24);

var domain241 = new Domain() { Name = "经理", Percent = 20 };
var domain242 = new Domain() { Name = "主管", Percent = 15 };
var domain243 = new Domain() { Name = "开发团队", Percent = 65 };
domain24.AddChild(domain241);
domain24.AddChild(domain242);
domain24.AddChild(domain243);

var domain2431 = new Domain() { Name = "项目组1", Percent = 50 };
var domain2432 = new Domain() { Name = "项目组2", Percent = 50 };
domain243.AddChild(domain2431);
domain243.AddChild(domain2432);

var domain24321 = new Domain() { Name = "项目经理", Percent = 20 };
var domain24322 = new Domain() { Name = "开发人员", Percent = 80 };
domain2432.AddChild(domain24321);
domain2432.AddChild(domain24322);

var domain243221 = new Domain() { Name = "高级开发", Percent = 40 };
var domain243222 = new Domain() { Name = "中级开发", Percent = 30 };
var domain243223 = new Domain() { Name = "初级开发", Percent = 20 };
var domain243224 = new Domain() { Name = "实习生", Percent = 10 };

domain24322.AddChild(domain243221);
domain24322.AddChild(domain243222);
domain24322.AddChild(domain243223);
domain24322.AddChild(domain243224);

var domain2432241 = new Domain() { Name = "实习生1", Percent = 25 };
var domain2432242 = new Domain() { Name = "实习生2", Percent = 25 };
var domain2432243 = new Domain() { Name = "实习生3", Percent = 25 };
var domain2432244 = new Domain() { Name = "实习生4", Percent = 25 };

domain243224.AddChild(domain2432241);
domain243224.AddChild(domain2432242);
domain243224.AddChild(domain2432243);
domain243224.AddChild(domain2432244);

#endregion

domain.Commission(total );

